import {request} from '@umijs/max';
import * as API from "@/services";
import {NotifyAnnouncePageQueryParams} from "@/services";


/**
 * 获取后端定义的所有枚举组
 */
export async function queryBackendEnums(enumTypeNames?: string, opts?: API.AxiosRequestOpts) {
    return request<API.RespListResult<API.BackendEnum>>('/api/v1/enums', {
        method: 'GET',
        params: {
            enumTypeNames
        },
        ...(opts || {}),
    });
}

// 通知
export async function queryNotifyReminds(params: API.NotifyRemindPageQueryParams): Promise<API.RespPageResult<API.NotifyRemind>> {
  return request('/api/v1/notify-remind/admin', {
    params,
  });
}
export async function queryMyNotifyReminds(params: API.NotifyRemindPageQueryParams): Promise<API.RespPageResult<API.NotifyRemind>> {
  return request('/api/v1/notify-remind', {
    params,
  });
}
// 通知 点击项标为已知
export async function readNotifyRemind(bizId: API.EntityId): Promise<API.RespResult<boolean>> {
  return request(`/api/v1/notify-remind/${bizId}/read`, {
    method: 'PUT',
  });
}
// 通知 全部标为已知
export async function readAllNotifyRemind(): Promise<API.RespResult<boolean>> {
  return request(`/api/v1/notify-remind/read`, {
    method: 'PUT',
  });
}

// 公告
export async function queryNotifyAnnounces(params: API.NotifyAnnouncePageQueryParams): Promise<API.RespPageResult<API.NotifyAnnounce>> {
  return request('/api/v1/notify-announce/admin', {
    params,
  });
}
export async function queryMyNotifyAnnounces(params: API.NotifyAnnouncePageQueryParams): Promise<API.RespPageResult<API.NotifyAnnounce>> {
  return request('/api/v1/notify-announce', {
    params,
  });
}
// 公告详情
export async function queryNotifyAnnounce(bizId: API.EntityId): Promise<API.RespResult<API.NotifyAnnounce>> {
  return request(`/api/v1/notify-announce/${bizId}`);
}

// 公告 点击项标为已读
export async function readNotifyAnnounces(bizId: API.EntityId): Promise<API.RespResult<boolean>> {
  return request(`/api/v1/notify-announce/${bizId}/read`, {
    method: 'PUT',
  });
}

// 公告 全部标为已知
export async function readAllNotifyAnnounces(): Promise<API.RespResult<boolean>> {
  return request(`/api/v1/notify-announce/read`, {
    method: 'PUT',
  });
}
